#include "pch.h"
#include "MyTrangle.h"

IMPLEMENT_SERIAL(MyTrangle, CGraph, 1)

MyTrangle::MyTrangle()
{
}

MyTrangle::MyTrangle(int DrawType, CPoint ptCenter, UINT OffsetDistance) :CGraph(DrawType, ptCenter, OffsetDistance) {

}

void MyTrangle::Draw(CDC* pDC)
{
	CPoint pt[3];
	pt[0] = CPoint(m_ptCenter.x, m_ptCenter.y - m_iOffsetDistance);
	pt[1] = CPoint(m_ptCenter.x - m_iOffsetDistance, m_ptCenter.y + m_iOffsetDistance);
	pt[2] = CPoint(m_ptCenter.x + m_iOffsetDistance, m_ptCenter.y + m_iOffsetDistance);
	pDC->Polygon(pt, 3);
}

void MyTrangle::Move(int x, int y)
{
	m_ptCenter.x += x;
	m_ptCenter.y += y;
}

void MyTrangle::Serialize(CArchive& ar)
{
	CGraph::Serialize(ar);

	if (ar.IsStoring())
		ar << m_iDrawType << m_ptCenter << m_iOffsetDistance;
	else
		ar >> m_iDrawType >> m_ptCenter >> m_iOffsetDistance;
}
